package com.lj.demo.invocation;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Title:
 * Description:
 * Date: 2019年07月17日 15:55
 * @author lvjie
 * @version 1.0
 * Significant Modify：
 * Date                  Author                 Content
 * =================================================================
 * 2019年07月17日         lvjie         创建文件,实现基本功能
 * =================================================================
 */
public class Invocation {

    /**
     * 目标对象
     */
    private Object target;

    /**
     * 参数集
     */
    private Object[] params;

    /**
     * 执行的方法对象
     */
    private Method method;

    /**
     * 反射执行方法
     * @return 执行结果
     * @throws InvocationTargetException
     * @throws IllegalAccessException
     */
    public Object proceed() throws InvocationTargetException, IllegalAccessException {
        return method.invoke(target,params);
    }

    public Invocation(Object target, Object[] params, Method method) {
        this.target = target;
        this.params = params;
        this.method = method;
    }

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    public Object[] getParams() {
        return params;
    }

    public void setParams(Object[] params) {
        this.params = params;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }
}
